package com.example.appgms;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

@SuppressLint("NewApi")
public class MainActivity extends Activity {
	
	private static LatLng Imhere =null;
	private static final LatLng esso = new LatLng(45.5056356, -73.6147537);
	private static final LatLng shell = new LatLng(45.5056356, -73.6146237);
	private static final LatLng petro = new LatLng(45.5076956, -73.6140837);
	
	private GoogleMap Gmap;
	private SupportMapFragment mMapFragment;
	private MapView mapView; 
	private static final int MILLION = 1000000; 
	MapController controller; 
	double lat; 
	double lon; 
	GeoPoint myPoint; 

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        Mymeth();
       
    }
   
    
    @SuppressLint("NewApi")
    private void Mymeth() {
    	if (Gmap == null) {
        	Gmap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
                                .getMap();
            if (Gmap != null) {
            	 Gmap.setMyLocationEnabled(true);
            	 //Imhere = new LatLng(Gmap.getMyLocation().getLatitude(), Gmap.getMyLocation().getLongitude());
            	 //AddMarker(Imhere,"Im here", "I'm here ;)", R.drawable.polymtl);
            	 System.out.println("getLatitude =====  " +Gmap.getMyLocation().getLatitude());
            	 System.out.println("getLongitude =====  " +Gmap.getMyLocation().getLongitude());
            	 AddMarker(esso,"esso", "esso is here ;)", R.drawable.esso); 
            	 AddMarker(shell,"shell", "shell is here ;)", R.drawable.shell); 
            	 AddMarker(petro,"petro", "petro is here ;)", R.drawable.petro); 
            	 
            	 
            	 
            }
        }
    }
    
    private void AddMarker(LatLng pos , String title, String message,  int ico) {
            	MarkerOptions mk = new MarkerOptions()
                .position(pos)
                .title(title)
                .snippet(message)
                //.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
                .icon(BitmapDescriptorFactory.fromResource(ico));
            	
            	
            	Gmap.addMarker(mk);
            	
    }
    
        
}
